*************************************************************************************
***** Reproduction of Manifesto-based salience measures and of Figures 2 and A3 *****
*************************************************************************************	
	
	/* To run this file download the Manifesto Project Dataset, Version 2020a, 
	available from: https://manifesto-project.wzb.eu/datasets/MPDS2020a
	
*************************************************************************************
	 If necessary, install missing ados and graph schemes. 
		ssc install carryforward
		ssc install blindschemes, replace all
	 */

*************************************************************************************	 
	 
	* general settings
		set more off, perm
		version 16.1	
	
	use "MPDataset_MPDS2020a_stata14.dta", clear

*************************************************************************************
	
	drop country
	rename countryname country 

	tostring date, gen(date2)
	gen year = substr(date2, 1, 4)
	order year, before(date)
	destring year, replace
	drop date2

	drop if oecdmember != 10

	sort country year

	#delimit ;
	drop if 
	country == "Czech Republic"
	| country == "Estonia"
	| country == "Hungary"
	| country == "Iceland"
	| country == "Israel"
	| country == "Latvia"
	| country == "Luxembourg"
	| country == "Malta"
	| country == "Mexico"
	| country == "Poland"
	| country == "Romania"
	| country == "Slovakia"
	| country == "Slovenia"
	| country == "South Korea"
	| country == "Turkey"	;  
	#delimit cr

	replace country="UK" if country=="United Kingdom"
	replace country="USA" if country=="United States"
		
	drop oecdmember eumember coderid manual coderyear test* corpusversion presvote peruncod voteest party ///
		progtype datasetorigin partyabbrev datasetversion id_perm
			
		
***** Salience economic dimension. (Main selection of items: econsal_party_f. Alternative selection used in the robustness section: econsal_party_sm)
	gen econsal_party_f=per401+per402+per407+per414+per505+per403+per404+per405+per406+per409+per412+per413+per415+per416+per504
	gen econsal_party_sm=per303+per401+per402+per407+per414+per505+per702+per403+per404+per406+per412+per413+per415+per503+per504+per701
			
***** Salience cultural dimensions. (Main selection of items: cultsal_r_party. Alternative selection used in the robustness section: cultsal_bh_party)
	gen cultsal_r_party=per109+per110+per305+per601+per603+per605+per608+per107+per108+per202+per502+per602+per604+per607+per705				
	gen cultsal_bh_party=per305+per601+per603+per605+per608+per606+per501+per602+per604+per502+per607+per416+per705+per706+per201+per202
	
	
***** Unweighted measures
	
	* Salience economic dimension per election
	bysort country edate: egen econsal_f=mean(econsal_party_f)
		* Non-left
		bysort country edate: egen econsal_f_nonl=mean(econsal_party_f) if parfam>30
		bysort country edate (econsal_f_nonl): carryforward econsal_f_nonl if econsal_f_nonl==., replace

	bysort country edate: egen econsal_sm=mean(econsal_party_sm)
												
	* Salience of the cultural dimension per election
	bysort country edate: egen cultsal_r=mean(cultsal_r_party)
		* Non-left
		bysort country edate: egen cultsal_r_nonl=mean(cultsal_r_party) if parfam>30
		bysort country edate (cultsal_r_nonl): carryforward cultsal_r_nonl if cultsal_r_nonl==., replace
		
	bysort country edate: egen cultsal_bh=mean(cultsal_bh_party)
	
	
	gen relsal_uw = econsal_f-cultsal_r
		* Non-left
		gen relsal_noLEFT = econsal_f_nonl-cultsal_r_nonl
							
	
***** Weighted measures

		/* Problematicly for the calculation of the weighted salience is that the aggregated vote shares of all parties per election (pervote) are 
		not equal to 100. Hence, I calculated adjusted vote shares that equal the share each party received among the aggregated original shares 
		per election, i.e. as if they would add up to 100 */
		bysort country date: egen totvote=sum(pervote)
		gen pervote_adj = pervote*(100/totvote)
			* Some parties are completeley without vote shares:
			drop if pervote==.	

	* Salience of the economic dimension per election
	bysort country edate: egen econsal_w_f=total((econsal_party_f*pervote_adj)/100)						
	bysort country edate: egen econsal_w_sm=total((econsal_party_sm*pervote_adj)/100)
					
	* Salience of the cultural dimension per election
	bysort country edate: egen cultsal_r_w=total((cultsal_r_party*pervote_adj)/100)
	bysort country edate: egen cultsal_bh_w=total((cultsal_bh_party*pervote_adj)/100)
						
	gen relsal_w = econsal_w_f-cultsal_r_w					
	gen relsal_w_alt = econsal_w_sm-cultsal_bh_w									
	
																				
***** Change the unit of observation from parties to elections
	bysort country edate: keep if _n==1
	keep country edate date year ///
	relsal_w relsal_uw relsal_w_alt relsal_noLEFT econsal_w_f	
	* If there were two elections during one year I only keep the last one, since polarisation from the previous election had almost no time to influence policy.
		sort country year (edate)
		bysort country: drop if year==year[_n-1]	
		sort country year
		save manifesto_salience, replace
	

	
************************************	
***** Reproduction of Figure 2 *****
************************************	

	use manifesto_salience, clear
			
	drop if country == "USA" | country == "New Zealand" | country == "Japan" | country == "Canada" | country == "Australia"
			
	bysort country: reg relsal_w year if year >= 1969 & year <=2011
				
	bysort country: egen cmean_relsal = mean(relsal_w) if year >= 1969 & year <=2011
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Austria" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.52", size(medium)) title(Austria) scheme(plotplainblind) name(Austria, replace)
					
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Belgium" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = .10", size(medium)) title(Belgium) scheme(plotplainblind) name(Belgium, replace)

					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Denmark" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.45", size(medium)) title(Denmark) scheme(plotplainblind) name(Denmark, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Finland" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = .08", size(medium)) title(Finland) scheme(plotplainblind) name(Finland, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="France" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.31", size(medium)) title(France) scheme(plotplainblind) name(France, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Germany" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.32", size(medium)) title(Germany) scheme(plotplainblind) name(Germany, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Greece" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = 1.11", size(medium)) title(Greece) scheme(plotplainblind) name(Greece, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Ireland" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = .09", size(medium)) title(Ireland) scheme(plotplainblind) name(Ireland, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Italy" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.02", size(medium)) title(Italy) scheme(plotplainblind) name(Italy, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Netherlands" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.45", size(medium)) title(Netherlands) scheme(plotplainblind) name(Netherlands, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Norway" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = .11", size(medium)) title(Norway) scheme(plotplainblind) name(Norway, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Portugal" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = .76", size(medium)) title(Portugal) scheme(plotplainblind) name(Portugal, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Spain" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.19", size(medium)) title(Spain) scheme(plotplainblind) name(Spain, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Sweden" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.31", size(medium)) title(Sweden) scheme(plotplainblind) name(Sweden, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="Switzerland" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.52", size(medium)) title(Switzerland) scheme(plotplainblind) name(Switzerland, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal year, color(gs4)) if country=="UK" ///
						& year >= 1969 & year <=2011, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) legend(off) ///
						text(-38 2004 "b = -.71", size(medium)) title(United Kingdom) scheme(plotplainblind) name(UK, replace)
			
	graph combine Austria Belgium Denmark Finland France Germany Greece Ireland Italy Netherlands Norway Portugal Spain Sweden Switzerland UK, ///
		l1(Relative salience of the economic dimension, size(small)) imargin(vsmall) iscale(*1.1) scheme(plotplainblind) name(Figure2, replace)
				

				
*************************************	
***** Reproduction of Figure A3 *****
*************************************	
				
	bysort country: reg relsal_w year if year >= 1969 & year <=2019
				
	bysort country: egen cmean_relsal_long = mean(relsal_w) if year >= 1969 & year <=2019
								
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Austria" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = -.30", size(medium)) title(Austria) scheme(plotplainblind) name(Austria, replace)
					
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Belgium" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = .12", size(medium)) title(Belgium) scheme(plotplainblind) name(Belgium, replace)

					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Denmark" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = -.44", size(medium)) title(Denmark) scheme(plotplainblind) name(Denmark, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Finland" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = .08", size(medium)) title(Finland) scheme(plotplainblind) name(Finland, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="France" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = -.22", size(medium)) title(France) scheme(plotplainblind) name(France, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Germany" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = -.19", size(medium)) title(Germany) scheme(plotplainblind) name(Germany, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Greece" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = 1.03", size(medium)) title(Greece) scheme(plotplainblind) name(Greece, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Ireland" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = .13", size(medium)) title(Ireland) scheme(plotplainblind) name(Ireland, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Italy" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = .02", size(medium)) title(Italy) scheme(plotplainblind) name(Italy, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Netherlands" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = -.31", size(medium)) title(Netherlands) scheme(plotplainblind) name(Netherlands, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Norway" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = .19", size(medium)) title(Norway) scheme(plotplainblind) name(Norway, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Portugal" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = .73", size(medium)) title(Portugal) scheme(plotplainblind) name(Portugal, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Spain" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = .13", size(medium)) title(Spain) scheme(plotplainblind) name(Spain, replace)
			
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Sweden" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = -.39", size(medium)) title(Sweden) scheme(plotplainblind) name(Sweden, replace)
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="Switzerland" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = -.39", size(medium)) title(Switzerland) scheme(plotplainblind) name(Switzerland, replace)	
						
					twoway (connected relsal_w year, lwidth(vthin)) (lfit relsal_w year) (line cmean_relsal_long year) if country=="UK" ///
						& year >= 1969 & year <=2019, ///
						xtitle("") yscale(range(-40 20)) ylabel(-40(20)20) yline(0) legend(off) ///
						text(-38 2013 "b = -.12", size(medium)) title(United Kingdom) scheme(plotplainblind) name(UK, replace)
			
			graph combine Austria Belgium Denmark Finland France Germany Greece Ireland Italy Netherlands Norway Portugal Spain Sweden Switzerland UK, ///
				l1(Relative salience of the economic dimension, size(small)) imargin(vsmall) iscale(*1.1) scheme(plotplainblind) name(FigureA3, replace) 